@extends('layouts.header')
@section('title','添加')
@section('content')
    <article class="page-container">
        <form class="form form-horizontal" id="myform" autocomplete="off">
            {{ csrf_form_field() }}
            <input type="text" class="hide" value="{{$info->id}}" name="id">
            <div class="row cl">
                <label class="form-label col-sm-3"><span class="c-red">*</span>名称：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text required" value="{{$info->name}}" placeholder="" id="name" name="name" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3"><span class="c-red">*</span>设备编号：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text required" value="{{$info->dev_num}}" placeholder="" id="dev_num" name="dev_num" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3"><span class="c-red">*</span>出厂编号：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text required" value="{{$info->fac_num}}" placeholder="" id="fac_num" name="fac_num" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">上级编号：</label>
                <div class="formControls col-sm-7">
                    <select name="pid" id="pid" class="input-text select2">
                        @foreach($data['parents'] as $item)
                            <option @if($item->dev_num === $data['pnum']) selected @endif value="{{$item->dev_num}}">{{$item->dev_num}}  --   {{$item->name}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">生产厂家：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" value="{{$info->factory}}" placeholder="" id="factory" name="factory" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3"><span class="c-red">*</span>型号/规格：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text required" value="{{$info->spec}}" placeholder="" id="spec" name="spec" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">量程范围：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" value="{{$info->ranges}}" placeholder="" id="ranges" name="ranges" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">准确度/等级：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" value="{{$info->accuracy}}" id="accuracy" name="accuracy" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">购入日期：</label>
                <div class="formControls col-sm-7">
                    <input type="date" class="input-text" value="{{$info->buy_date}}" id="buy_date" name="buy_date" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3"><span class="c-red">*</span>溯源方式：</label>
                <div class="formControls col-sm-7">
                    <select name="trace_type" id="trace_type" class="input-text required">
                        @foreach($data['trace_type'] as $val => $item)
                            <option @if($info->trace_type == $val) selected @endif value="{{$val}}">{{$item}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">溯源单位：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" value="{{$info->trace_com}}" id="trace_com" name="trace_com" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">溯源日期：</label>
                <div class="formControls col-sm-7">
                    <input type="date" class="input-text" value="{{$info->trace_date}}" id="trace_date" name="trace_date" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">溯源校准周期：</label>
                <div class="formControls col-sm-7">
                    <select name="trace_cycle" id="trace_cycle" class="input-text">
                        <option value="0">--请选择--</option>
                        @foreach($data['trace_cycle'] as $val => $item)
                            <option @if($info->trace_cycle == $val) selected @endif value="{{$val}}">{{$item}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3"><span class="c-red">*</span>负责人：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text required" value="{{$info->user}}" placeholder="" id="user" name="user" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3"><span class="c-red">*</span>设备状态：</label>
                <div class="formControls col-sm-7">
                    <select name="status" id="status" class="input-text required">
                        @foreach($data['status'] as $val => $item)
                            <option @if($info->status == $val) selected @endif value="{{$val}}">{{$item}}</option>
                        @endforeach
                    </select>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">温湿度设备编号：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" name="temp_hum_num" value="{{$info->temp_hum_num}}">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">气压设备编号：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" name="press_num" value="{{$info->press_num}}">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-sm-3">设备IP：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" value="{{$info->dev_lan_ip}}" placeholder="" id="dev_lan_ip" name="dev_lan_ip" autofocus="autofocus">
                </div>
            </div>

            <div class="row cl">
                <label class="form-label col-sm-3">显示器IP：</label>
                <div class="formControls col-sm-7">
                    <input type="text" class="input-text" value="{{$info->com_lan_ip}}" placeholder="" id="com_lan_ip" name="com_lan_ip" autofocus="autofocus">
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-sm-3">中控状态：</label>
                <div class="formControls col-sm-7">
                    <label><input type="radio" name="ishide" value="0" @if($info->ishide == 0) checked @endif>显示</label>
                    <label class="ml-20"><input type="radio" name="ishide" value="1" @if($info->ishide == 1) checked @endif>隐藏</label>
                </div>
            </div>

            @csrf
            <div class="row cl pt-20">
                <div class="col-sm-9 col-sm-offset-3">
                    <a class="btn btn-primary radius" id="sub">&nbsp;&nbsp;提交&nbsp;&nbsp;</a>
                    <input class="btn btn-danger radius ml-15" type="button" value="&nbsp;&nbsp;关闭&nbsp;&nbsp;" onclick="layer_close();">
                </div>
            </div>
        </form>
    </article>

    <script type="text/javascript">
        $(function () {
            $('.select2').select2();
            $("#sub").on('click', function () {
                if ($('#myform').valid()) {
                    ajaxForm('post', '', 'myform', formSub);

                    function formSub(data) {
                        //判断结果刷新
                        if (data === '1') {
                            parent.table_reload(0); //0停留在当前页，1回到第一页
                        }
                    }
                }
            });
        })
    </script>
    <!--/请在上方写此页面业务相关的脚本-->
@endsection
